package com.ruoyi.controller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.service.MaterielOneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/materielOne")
public class MaterielOneController {
    @Autowired
    private MaterielOneService materielOneService;

    //查询生产物信息1
    @GetMapping("/select")
    public R select(int page, int limit, String lotCode1, String itemCode, String lotCode, String docDate){
        if ((lotCode1 != null && !lotCode1.isEmpty() )||
                (itemCode != null && !itemCode.isEmpty())||
                (lotCode != null && !lotCode.isEmpty())||
                (docDate != null && !docDate.isEmpty())){
            return R.ok(materielOneService.selectMaterielOne(page,limit,lotCode1,itemCode,lotCode,docDate));
        }else{
            return R.ok(materielOneService.allMaterielOne(page,limit));
        }
    }

/*
    @PostMapping( "/createMaterielOne")
    public R createMaterielOne(@RequestParam("itemDescription")String itemDescription,
                               @RequestParam("itemCode")String itemCode,
                               @RequestParam("itemSpecification")String itemSpecification,
                               @RequestParam("lotCode")String lotCode,
                               @RequestParam("issuedQty")Double issuedQty,
                               @RequestParam("userName1")String userName1,
                               @RequestParam("reqIncludeMuQty")Double reqIncludeMuQty,
                               @RequestParam("lastModifyDate")String lastModifyDate,
                               @RequestParam("itemDescription1")String itemDescription1,
                               @RequestParam("lotCode1")String lotCode1
                              )  {

        // 将字符串转换为JSON
        JSONObject jsonContent = new JSONObject();
        jsonContent.put("itemDescription",itemDescription);
        jsonContent.put("itemCode", itemCode);
        jsonContent.put("itemSpecification", itemSpecification);
        jsonContent.put("lotCode", lotCode);
        jsonContent.put("issuedQty",issuedQty);
        jsonContent.put("userName1", userName1);
        jsonContent.put("reqIncludeMuQty", reqIncludeMuQty);
        jsonContent.put("lastModifyDate", lastModifyDate);
        jsonContent.put("itemDescription1", itemDescription1);
        jsonContent.put("lotCode1", lotCode1);

        return R.ok(jsonContent);
    }
*/

}

